/*  验证用户注册表单    */

/*使用jQuery实时验证*/
$(document).ready(function(){
    //验证昵称
    $("#nickname").change(function(){
        var reg = /^([\u4e00-\u9fa5]{3,15}$|^[0-9a-zA-Z_]{6,30})$/;
        var s = document.getElementById("nickname").value;
        if(!reg.test(s)) {
            document.getElementById("hint1").innerHTML = "× 错误";
            return false;
        }
        else {
            document.getElementById("hint1").innerHTML = "<span style = 'color:green;'>√ 正确</span>";
        }
    });
    //验证姓名
    $("#xm").change(function(){
        var reg = /^[\u4E00-\u9FA5]{2,7}$|^[\u4E00-\u9FA5]{2,5}(?:·[\u4E00-\u9FA5]{2,5})$|^[a-zA-Z]{1,30}$/;
        var s = document.getElementById("xm").value;
        
        if(!reg.test(s)) {
            document.getElementById("hint2").innerHTML = "× 错误";
            return false;
        }
        else {
            document.getElementById("hint2").innerHTML = "<span style = 'color:green;'>√ 正确</span>";
        }
    });
    //验证QQ号
    $("#qq").change(function(){
        var reg = /^[1-9][0-9]{4,10}$/;
        var s = document.getElementById("qq").value;
        
        if(!reg.test(s)) {
            document.getElementById("hint4").innerHTML = "× 错误";
            return false;
        }
        else {
            document.getElementById("hint4").innerHTML = "<span style = 'color:green;'>√ 正确</span>";
        }
    });
    //验证住址
    $("#address").change(function(){
        var reg = /^[\u4E00-\u9FFFa-zA-Z\d-]+$/;
        var s = document.getElementById("address").value;

        if(!reg.test(s)) {
            document.getElementById("hint5").innerHTML = "× 错误";
            return false;
        }
        else {
            document.getElementById("hint5").innerHTML = "<span style = 'color:green;'>√ 正确</span>";
        }
    });
});